<?php

// $Id$


require_once($WSC->get_site_inc_dir().'modules/tangra_cms/_sys/tcms_admin_page_w_fctrl_ua.class.php');
require_once($WSC->get_site_inc_dir().'modules/tangra_cms/forms/vpt_sa/vpt_sa_form_ctrl.class.php');


class VPT_SA_Edit_WP extends TCMS_Admin_Page_W_FCtrl_UA {
	public function create_view($name = 'default') {
		$ret = new TCMS_Admin_Page_View($this, $name, 'modules/tangra_cms/pages/_vpage/');

		return $ret;
	}


	protected function init_transit_vars() {
		$this->add_transit_var('template');
	}


	protected function create_form_ctrl() {
		$dbc = $this->get_dbc();
		$tvm = $this->get_tvm();

		$config = $this->get__config();

		$ret = new VPT_SA_Form_Ctrl('vpt_sa', $tvm, $dbc, 'obj_id', $config->get_hidden_dir());

		return $ret;
	}


	protected function on_add_new() {
		$this->form_ctrl->set_permanent_external_param('template', $this->get_transit_var('template'));
		$this->export('template_id', $this->get_transit_var('template'));
	}


	protected function on_received_id($object_id) {
		$this->form_ctrl->set_permanent_external_param('template', $this->get_transit_var('template'));
		$this->export('template_id', $this->get_transit_var('template'));
	}

	protected function create_default_redir_view() {
		$object = $this->form_ctrl->get_object();
		$redir_view = $this->create_redirect_view($this->get_redir_on_success(), array('manage' => $object->get_id()));

		return $redir_view;
	}
}